package others;

import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnels;

/**
 * @author ycz
 * @date 2021/8/3
 * 布隆过滤器
 */
public class BloomFilterTest {

    private static int size = 1000000;

    private static BloomFilter<Integer> bloomFilter = BloomFilter.create(Funnels.integerFunnel(),size);

    public static void main(String[] args) {
        for (int i=0;i<size;i++){
            bloomFilter.put(i);
        }
        long nanoTime = System.nanoTime();
        if(bloomFilter.mightContain(468456)&&bloomFilter.mightContain(456466)){
            System.out.println("命中了");
        }
        long endTime = System.nanoTime();
        System.out.println("运行时间 = "+(endTime-nanoTime));
    }


}
